package common;

/**
 * 公用的链表类
 * Created by Wongy on 2018/3/26.
 */
public class LinkNode {
    public int value;
    public LinkNode next;

    public LinkNode(int value) {
        this.value = value;
    }

    public LinkNode(int value, LinkNode next) {
        this.value = value;
        this.next = next;
    }

    public boolean hasNext() {
        return next != null;
    }

    @Override
    public String toString() {
        LinkNode p = this;
        StringBuilder sb = new StringBuilder(String.valueOf(p.value));
        while (p.hasNext()) {
            p = p.next;
            sb.append(",").append(p.value);
        }
        return sb.toString();
    }
}
